import { SYSTEM_CONFIG } from '@/store/mutation-types'
import { getSystemConfig } from '@/api/manage'

const state = {
  systemConfig: [],
}

const mutations = {
  [SYSTEM_CONFIG](state, data) {
    if (data.length > 0) {
      state.systemConfig = data
    }
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions: {
    getSystemConfig({ commit }, data) {
      getSystemConfig().then((res) => {
        if (res.code === 200) {
          commit(SYSTEM_CONFIG, res.data)
        }
      })
    },
  },
}
